﻿// Project: Salient
// http://salient.codeplex.com
// 
// Copyright 2010, Sky Sanders <sky at skysanders.net>
// Dual licensed under the MIT or GPL Version 2 licenses.
// http://salient.codeplex.com/license
// 
// Date: May 5 2010 

#region

using System.Web.Management;

#endregion

namespace SQLiteProviderStack
{

    public class SimpleSampleWebBaseEvent : WebBaseEvent
    {
        private readonly string _createMessage;
        private string _raisedMessage;

        public SimpleSampleWebBaseEvent(string msg, object eventSource, int eventCode) : 
            base(msg, eventSource, eventCode)
        {
            _createMessage = string.Format("Event created at: {0}", EventTime);
        }

        public SimpleSampleWebBaseEvent(string msg, object eventSource, int eventCode, int eventDetailCode) : base(msg, eventSource, eventCode, eventDetailCode)
        {
            _createMessage = string.Format("Event created at: {0}", EventTime);
        }


        public override void Raise()
        {
            _raisedMessage = string.Format("Event raised at: {0}", EventTime);

            base.Raise();
        }


        public override void FormatCustomEventDetails(WebEventFormatter formatter)
        {
            base.FormatCustomEventDetails(formatter);

            formatter.AppendLine("");
            formatter.IndentationLevel += 1;
            formatter.TabSize = 4;
            formatter.AppendLine("*SampleWebBaseEvent Start *");

            formatter.AppendLine(_createMessage);
            formatter.AppendLine(_raisedMessage);

            formatter.AppendLine("* SampleWebBaseEvent End *");


            formatter.IndentationLevel -= 1;
        }
    }
}